package com.wwl.io;

import java.io.*;

/**
 * 重定向：改变了System.in和System.out的原始设定，setIn或者setOut修改
 * 1 标准的输入设备：键盘
 * 2 标准的输出设备：屏幕
 */
public class IOChongDingXiang {

    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("data/score.txt");
        System.setIn(fis);
        BufferedReader br=new BufferedReader(new InputStreamReader(fis));

        String line=br.readLine();
        int num = 0;
        double sum=0;
        while(line != null){
            String[] arr = line.split(",");
            num++;
            sum=sum+Integer.parseInt(arr[1]);
            line=br.readLine();
        }
        System.out.println("avg="+(sum/num));

    }

}
